package com.zrc.japktool.util;

import org.apache.commons.codec.binary.Base64;

import java.nio.charset.StandardCharsets;

public class Base64Util {
    public static String encrypt(String input) {
        byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8);// 1. 字符串→字节数组：显式指定UTF-8（关键！与Kotlin的toByteArray(StandardCharsets.UTF_8)对齐）
        byte[] encodedBytes = Base64.encodeBase64(inputBytes);// 2. Base64加密：使用Apache工具类（与Kotlin的Base64.encodeBase64对齐）
        return new String(encodedBytes, StandardCharsets.UTF_8); // 3. 加密后字节数组→字符串：显式指定UTF-8（关键！与Kotlin的String(encodedBytes, StandardCharsets.UTF_8)对齐）
    }

    public static String decrypt(String input) {
        byte[] inputBytes = input.getBytes(StandardCharsets.UTF_8); // 1. 加密字符串→字节数组：使用UTF-8编码
        byte[] decodedBytes = Base64.decodeBase64(inputBytes);      // 2. Base64解密：使用Apache工具类
        return new String(decodedBytes, StandardCharsets.UTF_8);   // 3. 解密后字节数组→原始字符串：使用UTF-8编码
    }


    public static void main(String[] args) {
        String jjj="eyJhcHBVcmwiOiJodHRwOi8vNDcuMTA4LjY3LjE0OTo4MDgxLyIsImFwcERlYnVnIjp0cnVlLCJhcHBTb2Z0bnVtIjoiMjAyNFNBMDA0ODczNCIsImFwcENvbXBhbnlDb2RlIjowLCJhcHBTb2Z0YXV0aG9yIjoi5oiQ6YO95Lmd6ZyE6J6N5Yib56eR5oqA5pyJ6ZmQ5YWs5Y+4IiwiYXBwTmFtZSI6Iue7mOeUu+S5kOWbrSIsImFwcFBhY2thZ2UiOiJjb20ud2RoaGx5Lmh1YXdlaSIsImFwcFZlcnNpb25OYW1lIjoiMS4wLjQiLCJhcHBWZXJzaW9uQ29kZSI6MTA0LCJhcHBBY3QiOiJjb20uanhzZGsudml2by5kZW1vLmFwaS5NYWluQWN0aXZpdHkiLCJhcHBJZCI6IjExMzg0NjUyNyIsImFwcEtleSI6ImZkOGQ5MDJiYWM4MmRhMjY2OGVjMDc1NGU5NzkyMzllIiwiYXBwTWV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